//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#include "../Gather.h"

using namespace Native::System;
using namespace Native::Compiling;

CGather::CGather()
{
    _properies.KeyToString(UToString::FromObject);
}

CGather::CGather(C_GATHER& that) :
    CObject(that),
    _field(that._field),
    _properies(that._properies)
{
}

CGather::CGather(C_GATHER&& that) :
    CObject(that),
    _field(that._field),
    _properies(that._properies)
{
}

CGather::~CGather()
{
}

void CGather::Update() const
{
}

void CGather::Clear()
{
    _field.Clear();
    _properies.Clear();
}

void CGather::Collect(C_STRING& name, C_STRING& value) throw()
{
    try {
        _properies.Add(name.ToUpper(), value);
    } catch(CException& e) {
        NATIVE_THROW_CAUGHT(L"Collect", e);
    }
}

CString CGather::Get(C_STRING& name) throw()
{
    try {
        return _properies.Value(name.ToUpper());
    } catch(CException& e) {
        NATIVE_THROW_CAUGHT(L"Get", e);
    }
}

CString& CGather::Get(C_STRING& name) const throw()
{
    try {
        return _properies.Value(name.ToUpper());
    } catch(CException& e) {
        NATIVE_THROW_CAUGHT(L"Get", e);
    }
}

void CGather::CollectStarting(size_t starting)
{
    _field.Starting(starting);
}

void CGather::CollectEnding(size_t ending)
{
    _field.Ending(ending);
}

void CGather::CollectSequence(size_t sequence)
{
    _field.Sequence(sequence);
}

C_GATHER& CGather::operator=(C_GATHER& rvalue)
{
    CObject::operator=(rvalue);

    _field = rvalue._field;
    _properies = rvalue._properies;

    return *this;
}